#!/bin/sh

set -e

if [ "$1" = "configure" ]; then

	# Create the "tilemill" user
	if ! getent passwd mapbox > /dev/null; then
		adduser --quiet --system --group --home /usr/share/mapbox \
			--gecos "MapBox system user" \
			mapbox
	fi

	# Create files common to "tilemill" which need to be owned by the 
    # "tilemill" user
	install --owner mapbox --group mapbox --directory \
        	/var/log/tilemill
        # Ownership on tilemill home dir
        chown mapbox:mapbox /usr/share/tilemill
  # Create mapbox dir if it doesn't already exist.
  if [ ! -d "/usr/share/mapbox" ]; then
    install --owner mapbox --group mapbox --directory \
          /usr/share/mapbox
  fi
fi

echo "\nTileMill has been successfully installed. If you're using the Ubuntu launcher"
echo "\n(on 11.10 or later) you can start TileMill from there, or if not you can start"
echo "\nit by choosing Applications > Graphics > TileMill from the menu"

echo "\n\nYou can also start TileMill from the command line:"
echo "\n  node /usr/share/tilemill/index.js"

echo "\n\nLearn how to use TileMill"
echo "http://mapbox.com/tilemill/docs/"

echo "\n\nLearn how to run TileMill as an Ubuntu service"
echo "http://mapbox.com/tilemill/docs/guides/ubuntu-service/"
echo "\n"

#DEBHELPER#
